﻿using System;
using System.Linq;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Net;
using System.IO;
using Microsoft.WindowsCE.Forms;

namespace FlightLookup
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

        private void lookupMenuItem_Click(object sender, EventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;

            try
            {
                WebServices.Service ws = new WebServices.Service();
                //ws.Credentials = new NetworkCredential("uid", "pwd");
                resultTextBox.Text = ws.FlightLookup(flightTextBox.Text).Replace("\n", "\r\n");
            }
            catch(Exception ex)
            {
                Cursor.Current = Cursors.Default;
                MessageBox.Show(ex.Message);
            }
            Cursor.Current = Cursors.Default;
        }

        private void doneMenuItem_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private bool inputNumeric = false;
        private void flightTextBox_TextChanged(object sender, EventArgs e)
        {
            if(flightTextBox.Text.Length >= 3 && !inputNumeric)
            {
                InputModeEditor.SetInputMode(flightTextBox, InputMode.Numeric);
                inputNumeric = true;
            }
            else if(flightTextBox.Text.Length < 3 && inputNumeric)
            {
                InputModeEditor.SetInputMode(flightTextBox, InputMode.Default);
                inputNumeric = false;
            }
        }
    }
}